## r r+ w w+ a a+
if File.file?( "text.txt" )
    file = File.new("test.txt","r+")
else file = File.new("test.txt","w+") end
if file 
    puts file.syswrite("hello world")
    puts file.syswrite("hello world")
    
    # file.close
else puts "file no open!" end
if file
    file = File.new("test.txt","r+")
    puts file.sysread(5)
else puts "file no open!"
end 
if file
    file = File.new("test.txt","w")
    puts file.syswrite(Time.new)
else puts "file no open!"
end
if file
    file = File.new("test.txt","r")
    # puts file.syswrite(Time.new)
    puts file.sysread(25)
else puts "file no open!"
end
if file
    file = File.new("test.txt","a")
    puts file.syswrite(" I write a little information")
    file = File.new("test.txt","a+")
    puts file.sysread(25+29)
else puts "file no open!"
end
if file
    file = File.new("test.txt","a+")
    puts file.syswrite(" \nI again write a little information")
    file.rewind
    puts file.sysread(25+29+34)
else puts "file no open!"
end
# if file 
#     file.rewind
#     putc file.each_byte {|ch| putc ch; putc '.' }
# else puts "file no open!"
# end
if file
    file.rewind
    puts "readLines:",file.readlines("test.txt")
else puts "file no open!"
end
IO.foreach("test.txt"){|line| puts line}
